Don't create temporary files for <video>
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 9 Nov 2021 06:10:18 +0000 (07:10 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 9 Nov 2021 06:47:17 +0000 (07:47 +0100)
* lisp/net/shr.el (shr-tag-audio): Don't create a temporary file;
just update the DOM directly.

lisp/net/shr.el

index d5d6d63fdde3ae39baf276287802efcf9f7ecf82..19d2d8a8e6ba810bc552bfd21aa525d9123ede02 100644 (file)
@@ -1685,23 +1685,16 @@ The preference is a float determined from `shr-prefer-media-type'."
                          'webkit
                         "Video"
                          (truncate (* (window-pixel-width) 0.8))
-                         (truncate (* (window-pixel-width) 0.8 0.75))))
-                (file (make-temp-file "shr" nil ".html")))
-            (run-at-time 1 nil (lambda ()
-                                 (ignore-errors
-                                   (delete-file file))))
+                         (truncate (* (window-pixel-width) 0.8 0.75)))))
             (insert
              (propertize
               " [video] "
               'display (list 'xwidget :xwidget widget)))
-            (with-temp-buffer
-              (insert
-               (format
-                "<video autoplay loop muted><source src=%S type=\"video/mp4\"></source></video>"
-                url))
-              (write-region (point-min) (point-max) file nil 'silent))
-            (xwidget-webkit-goto-uri widget
-                                     (concat "file://" file))))
+            (xwidget-webkit-execute-script
+             widget (format "document.body.innerHTML = %S;"
+                            (format
+                             "<video autoplay loop muted><source src=%S type='video/mp4\'></source></video>"
+                             url)))))
       ;; No xwidgets.
       (if (> (length image) 0)
          (shr-indirect-call 'img nil image)